<template>
  <el-dropdown @command="commandEvent">
    <div class="icon">
      <svg-icon icon-class="language" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          command="zh"
          :disabled="$i18n.locale === 'zh'"
        >中文</el-dropdown-item>
        <el-dropdown-item
          command="en"
          :disabled="$i18n.locale === 'en'"
        >english</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    commandEvent(command) {
      this.$i18n.locale = command
      jsCookie.set('lang', command)
      //   刷新网站
      this.$router.go(0)
    }
  }
}
</script>
<style lang="scss" scoped>
.icon {
  font-size: 26px;
  color: #fff;
}
</style>
